package com.Utils;

public class Clock {
    private double StartTime;
    private int clockTime=99;
    private double GameStartTime;
    private boolean judgement = false;
    private int round = 0;

    //程序运行开始时间
    public Clock() {
        StartTime = System.currentTimeMillis();

    }

    //返回游戏已经运行的时间
    public double getRunningTime() {
        return System.currentTimeMillis() - StartTime;
    }

    //游戏开始
    public void setGameStartTime() {
        GameStartTime = System.currentTimeMillis();
        judgement = true;

    }

    //获取游戏开始时间
    public double getGameStartTime() {
        return GameStartTime;
    }

    //获取时钟时间
    public long getClockTime(){
        return clockTime;
    }
    //更新时钟时间
    public void updateTime() {

        if (judgement) {
            clockTime = 99  - (int)((System.currentTimeMillis() - getGameStartTime())/1000);

            if (clockTime == 0) {
                judgement = false;
                GameStartTime=System.currentTimeMillis();
            }
        }
    }
}






